package webdesigntools.mtbrowser;
/*
 * 
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 * 
 */


import java.awt.Toolkit;
import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.BoxLayout;
import javax.swing.Box;
import javax.swing.JRadioButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.DefaultButtonModel;

public class BrowsersList extends JPanel
{
	public BrowsersList()
	{
		setLayout(new BorderLayout());
		setBorder(new TitledBorder(
						new EtchedBorder(),
						"Browsers"));
		
		browsersList = Box.createVerticalBox();
	    browsersList.setMaximumSize(new Dimension(100,30));

		browsersList.add(Box.createVerticalStrut(10));
		browsersList.add(firefox= new JRadioButton("Firefox"));
		
		browsersList.add(Box.createVerticalStrut(10));
		browsersList.add(mozilla = new JRadioButton("Mozilla"));

		browsersList.add(Box.createVerticalStrut(10));
		browsersList.add(explorer = new JRadioButton("Internet Explorer"));
		
		browsersList.add(Box.createVerticalStrut(10));
		browsersList.add(netscape = new JRadioButton("Netscape"));
		
		browsersList.add(Box.createVerticalStrut(10));
		browsersList.add(opera = new JRadioButton("Opera"));

		browsersList.add(Box.createVerticalStrut(10));
		browsersList.add(konqueror = new JRadioButton("Konqueror"));

		add(browsersList,BorderLayout.CENTER);
		
		//Test Finding browsers
		try{
			findBrowsers();
		}catch(Exception e){ System.out.println(e.getMessage());}

	}
	private void findBrowsers() throws MtBrowserException
	{
		DefaultButtonModel model;
		if(!FindBrowsers.check("firefox").equals(""))
		{
			model = (DefaultButtonModel)firefox.getModel();
			model.setSelected(true);
		}if(!FindBrowsers.check("mozilla").equals(""))
                {
			model = (DefaultButtonModel)mozilla.getModel();
			model.setSelected(true);
		}if(!FindBrowsers.check("explorer").equals(""))
		{
			model = (DefaultButtonModel)explorer.getModel();
			model.setSelected(true);
		}if(!FindBrowsers.check("netscape").equals(""))
		{
			model = (DefaultButtonModel)netscape.getModel();
			model.setSelected(true);
		}if(!FindBrowsers.check("opera").equals(""))
		{
			model = (DefaultButtonModel)opera.getModel();
			model.setSelected(true);
		}if(!FindBrowsers.check("konqueror").equals(""))
		{
			model = (DefaultButtonModel)konqueror.getModel();
			model.setSelected(true);
		}	
	}
	
	private Box browsersList, right;
	private JRadioButton firefox, mozilla, explorer, netscape, opera, konqueror;
}
